import time
from timeit import timeit

from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.wait import WebDriverWait

driver = webdriver.Chrome(executable_path='Chromedriver.exe')
# driver.get("http://121.43.169.97:8848/pageB.html")
url = r"C:\Users\Admin\PycharmProjects\UI自动化测试\注册实例.html";
driver.get(url)

# 1.获取‘表单综合实例.html’当前窗口句柄
# 目的：判断只要不是当前窗口句柄，就一定是新窗口句柄
current_handle = driver.current_window_handle
print("综合实例当前窗口句柄:",current_handle)

# 2). 点击注册页面A连接
driver.find_element_by_partial_link_text("A网页").click()
# 3.获取所有窗口句柄
handle = driver.window_handles
print("所有窗口句柄:",handle)


# 4.获取注册页面A窗口句柄,并切
# 判断 不是‘当前窗口句柄’
for i in handle:
    if i != current_handle:
#         切换
         driver.switch_to_window(i)
# 用户名
         driver.find_element_by_css_selector("#userA").send_keys("admin")
# 密码
         driver.find_element_by_css_selector("#passwordA").send_keys("123456")
# 电话号码
         driver.find_element_by_css_selector("#telA").send_keys("18776895770")
# 电子邮件
         driver.find_element_by_css_selector("#emailA").send_keys("123@qq.com")




